/**
 * 组件：ImageButton 图片按钮组件
 * Author:Colin3dmax
 */
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {
    StyleSheet,
    View,
    Text,
    Image,
    TouchableOpacity,
} from 'react-native';
import Util from '../utils/util';

class WindowPanel extends Component {

    static propTypes = {
        title:PropTypes.string,
        iconSource:Image.propTypes.source,
        style: View.propTypes.style,
        titleTextStyle: View.propTypes.style,
        titleIconStyle:Image.propTypes.style,
        titleBarStyle: View.propTypes.style,
        bodyStyle: View.propTypes.style,
        onPressTitleBar: PropTypes.func,
    }

    static defaultProps = {}

    constructor(props) {
        super(props)
        this.state = {}
    }

    componentDidMount() {

    }


    render() {
        const {title,iconSource,style, bodyStyle, titleBarStyle, titleTextStyle,titleIconStyle, onPressTitleBar,children} = this.props
        return (
            <View style={styles.winPanel}>
                <TouchableOpacity onPress={onPressTitleBar}>
                    <View style={[styles.winPanelTitle, titleBarStyle]}>
                        {iconSource && <Image source={iconSource} style={[styles.titleBarIcon,titleIconStyle]}/>}
                        <Text style={[styles.winPanelTitleText, titleTextStyle]}>{title}</Text>
                    </View>
                </TouchableOpacity>
                <View style={styles.splitLine}/>
                <View style={[styles.winPanelBody, bodyStyle]}>
                    {children}
                </View>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    winPanel: {
        marginTop: 8,
        backgroundColor: 'white',
    },
    winPanelTitle: {
        height: 40,
        flexDirection: 'row',
        alignItems: 'center',
        paddingLeft: 8,
        paddingRight: 8,
    },
    titleBarIcon:{
        marginRight:4,
        width:22,
        height:22,
        resizeMode:'contain',
    },
    winPanelTitleText: {
        fontSize: 14,
        color: '#707070',
    },
    splitLine:{
        height:Util.getRealPixel(1),
        backgroundColor:'#EDEDEF',
        // marginLeft:8,
    },
    winPanelBody: {},

});

export default WindowPanel;